package com.hustzp.com.xichuangzhu.me;

import android.os.Bundle;
import android.widget.CompoundButton;
import android.widget.TextView;
import android.widget.ToggleButton;

import com.hustzp.com.xichuangzhu.R;
import com.hustzp.com.xichuangzhu.XichuangzhuApplication;

/**
 * Created by Administrator on 2016/6/5.
 */
public class PushMsgActivity extends MyBaseActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_push_msg);

        initToolbar();
        initViews();
    }

    private void initToolbar() {
        TextView navTxt = (TextView) findViewById(R.id.tv_nav_txt);
        navTxt.setText("设置");
        TextView appTitle = (TextView) findViewById(R.id.tv_title_txt);
        appTitle.setText("消息通知");
    }

    private void initViews() {
        ToggleButton msgToggleBtn = (ToggleButton) findViewById(R.id.toggle_msg_btn);
        msgToggleBtn.setChecked(XichuangzhuApplication.getInstance().getPushMsgCfg());

        msgToggleBtn.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                if (isChecked) {
                    showToastInfo("开启消息推送");
                } else {
                    showToastInfo("关闭消息推送");
                }
                XichuangzhuApplication.getInstance().savePushMsgCfg(isChecked);
            }
        });
    }


}
